/**
 * 
 */
package com.topline.xiaocaifeng.error;

import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import org.springframework.boot.autoconfigure.web.ErrorViewResolver;
import org.springframework.http.HttpStatus;
import org.springframework.stereotype.Component;
import org.springframework.web.servlet.ModelAndView;

/**
 * @author Administrator
 *
 */
@Component
public class MyErrorResolver  implements ErrorViewResolver{

    @Override
    public ModelAndView resolveErrorView(HttpServletRequest request, HttpStatus status, Map<String, Object> model) {
        ModelAndView modelAndView = new ModelAndView();
        // TODO Auto-generated method stub
        if(status.is5xxServerError()){
            modelAndView.setViewName("5xx");
        }else if(status.is4xxClientError()){
            modelAndView.setViewName("6xx");
        }
        return modelAndView;
    }

}
